
<ui:composition xmlns="http://www.w3.org/1999/xhtml" xmlns:f="http://java.sun.com/jsf/core"
	xmlns:p="http://primefaces.org/ui" xmlns:h="http://java.sun.com/jsf/html"
	xmlns:ui="http://java.sun.com/jsf/facelets" template="/template/main.xhtml">

	<ui:define name="body">
		<h:form prependId="false" id="form">
			<p:toolbar  >
				<p:toolbarGroup align="left">

					<p:commandButton  title="#{messages['button.delete']}" value="Registrar Produção Concluida" onclick="confirmation.show()"
						type="button" immediate="true" ajax="false" />

					<p:dialog style="position: absolute; left:50px; top:50px;"  message="#{messages['label.confirm.delete']}" showEffect="bounce" hideEffect="explode" header="#{messages['label.dialog.alert']}!" severity="alert" widgetVar="confirmation"  width="300">
						<h:panelGrid columns="2">
							<h:commandButton value="#{messages['button.dialog.yes']}" action="#{pedidoAgendarMB.deletesSelection()}" actionListener="#{pedidoAgendarMB.clear}" />
							<h:commandButton value="#{messages['button.dialog.no']}" onclick="confirmation.hide()" type="button" />
						</h:panelGrid>
					</p:dialog>

					<p:dialog style="position: absolute; left:50px; top:50px;"  message="Data da Produção" showEffect="bounce" hideEffect="explode" width="800"
						header="#{messages['label.dialog.alert']}!" severity="alert" widgetVar="confirmationInserirData">
						<h:panelGrid columns="1" id="inserirData">
						
							<h:panelGrid columns="1">
								<h:outputLabel value="#{pedidoAgendarMB.idPedido}: " styleClass="text-input" />
								<h:inputHidden value="#{pedidoAgendarMB.idPedido}" />
							</h:panelGrid>
	
							<h:panelGrid columns="8">
								<p:calendar id="dataEntrega" value="#{pedidoAgendarMB.dataProducao}"  
									required="true" requiredMessage="#{messages['mensagem_geral.campoObrigatorio']}" 
								   	pattern="#{messages['label.date.pattern']}" navigator="true" showButtonPanel="true"
								   	locale="#{currentLocale}" title="#{messages['pedido.alt.dataEntrega']}" />
								<p:message for="dataEntrega" />
	
								<h:outputLabel value="#{messages['pedido.label.hora']}: " for="hora" styleClass="text-input" />
								<h:selectOneMenu value="#{pedidoAgendarMB.hora}" id="hora" style="width: 80px;"
									title="#{messages['pedido.label.hora']}" required="true"
									requiredMessage="#{messages['mensagem_geral.campoObrigatorio']}">
			 						<f:selectItems value="#{pedidoAgendarMB.horas}"></f:selectItems>
								</h:selectOneMenu>
								<p:message for="hora" />
								<h:outputText value=" : " />
								<h:selectOneMenu value="#{pedidoAgendarMB.minuto}" id="minuto" style="width: 80px;"
									title="#{messages['pedido.label.minuto']}" required="true"
									requiredMessage="#{messages['mensagem_geral.campoObrigatorio']}">
			 						<f:selectItems value="#{pedidoAgendarMB.minutos}"></f:selectItems>
								</h:selectOneMenu>
								<p:message for="minuto" />
	
								<h:commandButton value="Alterar" actionListener="#{pedidoAgendarMB.alterarProducao()}" />
								<h:commandButton value="Cancelar" onclick="confirmationInserirData.hide()" type="button" />
	
							</h:panelGrid>	
						</h:panelGrid>
					</p:dialog>

				</p:toolbarGroup>
			</p:toolbar>

			<br />
<div style="overflow: auto; width: 100%; height: 300;">
			<h:commandButton value="Marcar Todos"  actionListener="#{pedidoAgendarMB.marcar()}" ajax="true" >
		    		<f:ajax execute="list" render="list" />
		    </h:commandButton>
		    	
			<p:dataTable id="list" var="bean" value="#{pedidoAgendarMB.resultList}">
				<p:column style="width:1%;">
					<h:selectBooleanCheckbox value="#{pedidoAgendarMB.selection[bean.id]}"></h:selectBooleanCheckbox>
				</p:column>
				
				<p:column style="width:5%;font-size:12;" sortBy="#{bean.id}">
					<f:facet name="header">#{messages['pedido.label.id']}</f:facet>
					<h:outputText value="#{bean.id}" />
				</p:column>

				<p:column style="font-size:12;" sortBy="#{bean.cliente}">
					<f:facet name="header">#{messages['pedido.label.cliente']}</f:facet>
					<h:outputText value="#{bean.cliente.nome}" />
				</p:column>

				<p:column style="font-size:12;">
					<f:facet name="header">#{messages['pedido.label.dataAgendamento']}</f:facet>

					<p:commandLink title="Sem Agendamento" value="Sem Agendamento" update=":form:inserirData" rendered="#{empty bean.dataProducao}"
					onclick="confirmationInserirData.show()" ajax="true" style="font-size:12;" >
						<f:setPropertyActionListener value="#{bean.id}" target="#{pedidoAgendarMB.idPedido}" />
					</p:commandLink>
					
					<p:commandLink  update=":form:inserirData" rendered="#{not empty bean.dataProducao}"
					onclick="confirmationInserirData.show()" ajax="true" style="font-size:12;" >
						<h:outputText value="#{bean.dataProducao}"  converter="dateConverter"  />
						<h:outputText value=" - "  rendered="#{not empty bean.dataProducao}"/>
						<h:outputText value="#{bean.horaProducao}"   />
						<h:outputText value=":"  rendered="#{not empty bean.dataProducao}" />
						<h:outputText value="#{bean.minutoProducao}"   />
						<f:setPropertyActionListener value="#{bean.id}" target="#{pedidoAgendarMB.idPedido}" />
					</p:commandLink>
				</p:column>

				<p:column style="font-size:12;" sortBy="#{bean.dataCadastro}">
					<f:facet name="header">#{messages['pedido.label.dataCadastro']}</f:facet>
					<h:outputText value="#{bean.dataCadastro}"  converter="dateConverter"  />
				</p:column>
						
				<p:column style="font-size:12;" sortBy="#{bean.dataEntrega}">
					<f:facet name="header">#{messages['pedido.label.dataEntrega']}</f:facet>
					<h:outputText value="#{bean.dataEntrega}"  converter="dateConverter"  />
					<h:outputText value=" - "  />
					<h:outputText value="#{bean.hora}"  />
					<h:outputText value=":"  />
					<h:outputText value="#{bean.minuto}"  />
				</p:column>

				<p:column style="font-size:12;" sortBy="#{bean.statusPedido}">
					<f:facet name="header">#{messages['pedido.label.statusPedido']}</f:facet>
					<h:outputText value="#{bean.statusPedido.descricao}" />
				</p:column>
						
				<p:column style="font-size:12;" sortBy="#{bean.valorTotalPedido}">
					<f:facet name="header">#{messages['pedido.label.valorTotalPedido']}</f:facet>
					<h:outputText value="#{bean.valorTotalPedido}"  converter="bigDecimalConversor"  />
				</p:column>
						
			</p:dataTable>
</div>
			
		</h:form>

	</ui:define>
</ui:composition>